package com.cjm.one.controller.goods;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cjm.one.common.result.Result;
import com.cjm.one.model.coupon.entity.CouponInfo;
import com.cjm.one.model.goods.entity.GoodsCategory;
import com.cjm.one.model.goods.vo.GoodsCategoryVo;
import com.cjm.one.service.GoodsCategoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@Tag(name = "商品分类", description = "商品分类管理")
@RequestMapping("/api/category/")
public class GoodsCategoryController {
    @Resource
    private GoodsCategoryService goodsCategoryService;

    @GetMapping("/listLimit10")
    public Result<List<GoodsCategory>> listLimit10(@RequestParam(value = "size",required = false) Integer size) {
        log.info("商品分类列表");
        return goodsCategoryService.listLimit10(size);
    }
    @GetMapping("/byParentId")
    @Operation(summary = "根据父id获取商品分类列表")
    Result<List<GoodsCategory>> selectToParentId(@RequestParam(name="parentId",required = false) Long parentId){
        return goodsCategoryService.selectToParentId(parentId);

    }
}
